<template>
  <div class="edit-content">
    <div class="all-job-resume" style="padding:24px 0 0 0; background:#f7fdff;">
      <div class="all-job-resume-head">
        <span class="all-job-resume-line"></span>
        基本信息
        <span class="all-job-resume-sub-text">必填</span>
      </div>
      <el-form label-width="100px" :model="resumeTalentInfo" label-position="right">
        <el-row>
          <el-col :span="12">
            <el-form-item label="姓名">
              <el-input v-model="resumeTalentInfo.talentName" class="theme-input all-input"></el-input>
            </el-form-item>
            <el-form-item label="年龄">
              <el-input v-model="resumeTalentInfo.talentAge" class="theme-input all-input"></el-input>
            </el-form-item>
            <el-form-item label="所在城市">
              <el-cascader :options="city" @change="getData" placeholder="所在城市" v-model="workCity"></el-cascader>
            </el-form-item>
            <el-form-item label="电话号码">
              <el-input
                class="theme-input all-input"
                v-model="resumeTalentInfo.phoneNumber"
                disabled
              ></el-input>
              <el-button type="text" class="chang-button" @click="doChange">更改</el-button>
            </el-form-item>
          </el-col>
          <el-col :span="11" :offset="1">
            <el-form-item label="求职状态">
              <el-select
                class="theme-input all-input"
                v-model="resumeTalentInfo.jobState"
                placeholder="请选择求职状态"
              >
                <el-option
                  v-for="(item,index) in jobSta"
                  :label="item.content"
                  :value="item.id"
                  :key="index"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="工作年限">
              <el-input v-model="resumeTalentInfo.workDay" class="theme-input all-input"></el-input>
            </el-form-item>
            <el-form-item label="当前年薪">
              <el-col :span="12">
                <el-input v-model="resumeTalentInfo.salaryPerMonth" class="theme-input money-input"></el-input>&nbsp;W/&nbsp;
                <el-input v-model="resumeTalentInfo.monthCount" class="theme-input money-input"></el-input>&nbsp;年
              </el-col>
              <el-col :span="12">
                <el-radio-group v-model="resumeTalentInfo.tax">
                  <el-radio :label="0">税前</el-radio>
                  <el-radio :label="1">税后</el-radio>
                </el-radio-group>
              </el-col>
            </el-form-item>
            <el-form-item label="电子邮箱">
              <el-input v-model="resumeTalentInfo.email" class="theme-input all-input"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item class="form-button-right">
          <el-button class="ghost-button" @click="cancel">取消</el-button>
          <el-button class="submit-button" @click="onSubmit">确认</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { chinaOptions, CodeToText, TextToCode } from '@/assets/utils/china.js'
export default {
  props: ['jobSta', 'cityType', 'resumeTalentInfo', 'form'],
  data() {
    return {
      city: chinaOptions,
      workCity: []
    }
  },
  methods: {
    check() {
      if (
        this.resumeTalentInfo.talentName == '' ||
        this.resumeTalentInfo.talentAge == '' ||
        this.workCity == '' ||
        this.resumeTalentInfo.email == '' ||
        this.resumeTalentInfo.jobState == '' ||
        this.resumeTalentInfo.workDay == '' ||
        this.resumeTalentInfo.salaryPerMonth == '' ||
        this.resumeTalentInfo.monthCount == ''
      ) {
        _g.message('基本信息不能为空', 'warning')
        return false
      }
      return true
    },
    cancel() {
      this.form.sta = -1
      this.form.editSta = -1
    },
    onSubmit() {
      if (!this.check()) return false
      let params = {
        name: this.resumeTalentInfo.talentName,
        age: this.resumeTalentInfo.talentAge,
        city: this.resumeTalentInfo.workCity,
        email: this.resumeTalentInfo.email,
        jobState: this.resumeTalentInfo.jobState,
        workDay: this.resumeTalentInfo.workDay,
        salaryPerMonth: this.resumeTalentInfo.salaryPerMonth,
        monthCount: this.resumeTalentInfo.monthCount,
        tax: this.resumeTalentInfo.tax
      }
      _g.apiPost('/talent/updateTalentInfo.do', params).then(res => {
        _g.toMessage({
          status: res.status,
          msg: res.status == 0 ? '修改成功' : '参数错误'
        })

        this.$emit('on-pitch', true)
        this.cancel()
      })
    },
    getData(val) {
      this.resumeTalentInfo.workCity = val.join('-')
    },
    setCity() {
      this.workCity = this.resumeTalentInfo.workCity.split('-')
    },
    doChange() {
      this.$router.push({ path: '/setting/binding' })
    }
  },
  mounted() {
    this.setCity()
  },
  components: {}
}
</script>

<style lang="scss" scoped>
.chang-button {
  margin: 0 0 0 5px;
  color: #f09338;
}
</style>
